package com.lzj.demo.design.strategy.fzw;

import org.springframework.stereotype.Component;

import java.math.BigDecimal;

/**
 * 直减计算
 * 1.使用商品价格减去优惠价格
 * 2.最低支付1元
 * */
@Component
public class ZJCoupon implements ICoupon{
    @Override
    public BigDecimal discountAccount(BigDecimal skuPrice) {
        BigDecimal discountAmount = skuPrice.subtract(CouponEnum.ZJ.getPrice());
        if(discountAmount.compareTo(BigDecimal.ZERO) < 1){
            return BigDecimal.ONE;
        }
        return discountAmount;
    }

    @Override
    public CouponEnum getCoupon() {
        return CouponEnum.ZJ;
    }
}
